package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.*;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/destinations")
public class DestinationController {

    @Autowired
    private IRegionService regionService;
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private ITravelService travelService;

    @GetMapping("/hotRegion")
    public Object hotRegion(){

        List<Region> list = regionService.queryHotRegion();

        return JsonResult.success(list);
    }

    @GetMapping("/search")
    public Object search(String regionId){

        List<Destination> list = destinationService.search(regionId);

        return JsonResult.success(list);
    }

    @GetMapping("/toasts")
    public Object toasts(String destId){
        List<Destination> toasts = destinationService.getToasts(destId);

        return JsonResult.success(toasts);
    }

    @GetMapping("/detail")
    public Object detail(String id){

        Destination dest = destinationService.find(id);
        return JsonResult.success(dest);
    }

    @GetMapping("/catalogs")
    public Object catalogs(String destId){
        //根据destId查询所有攻略分类及明细
        List<StrategyCatalog> list = strategyCatalogService.queryStrategyDetail(destId);
        System.out.println(list);
        return JsonResult.success(list);
    }

    @GetMapping("/strategies/viewnumTop3")
    public Object viewnumTop3(String destId){

        List<Strategy> strategies = strategyService.viewnumTop3(destId);

        return JsonResult.success(strategies);
    }

    @GetMapping("/travels/viewnumTop3")
    public Object travelViewnumTop3(String destId){

        List<Travel> travels = travelService.viewnumTop3(destId);

        return JsonResult.success(travels);
    }
}
